from request import get_user_detail_info
from config import *
import json
import time

first = True
last_fans = 0
now_fans = 0

while True:
    json_data = get_user_detail_info(cookie, query, token, user_agent, user_id, sec_user_id)
    fans = int(json.loads(json_data)['user']['followers_detail'][0]['fans_count'])
    if first:
        last_fans = fans
        first = False

    now_fans = fans
    add = now_fans - last_fans
    last_fans = now_fans

    now_time = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())
    log_time = time.strftime("%Y-%m-%d", time.localtime())
    print(now_time, " ", fans, " ", add)
    add_log(log.format(log_time), now_time, fans, add)
    time.sleep(300)
